//package com.siwei.eqi.pojo.vo;
//
//import com.siwei.eqi.pojo.entity.RegionEntity;
//import lombok.Data;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.logging.log4j.core.util.JsonUtils;
//import org.springframework.util.CollectionUtils;
//
//import java.math.BigDecimal;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * {"type": "FeatureCollection",
// * "name": "广东省",
// * "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// * "features": [
// * { "type": "Feature", "properties": { "name": "梅州市", "code": "441400","pname": "广东省", "pcode": "440000",x:"",y:"" }, "geometry": { "type": "MultiPolygon", "coordinates": []}}]}
// */
//@Data
//public class RegionVO {
//
//    private String type = "FeatureCollection";
//
//    private String name;
//
//    private Crs crs;
//
//    private List<Feature> features;
//
//    @Data
//    public static class Crs{
//        private String type = "name";;
//
//        private CrsProperties properties ;
//    }
//
//    @Data
//    public static class CrsProperties{
//        private String name = "urn:ogc:def:crs:OGC:1.3:CRS84";
//    }
//
//    @Data
//    public static class Properties{
//        private String name;
//
//        private String code;
//
//        private String pname;
//
//        private String pcode;
//
//        private BigDecimal x;
//
//        private BigDecimal y;
//
//        private Boolean leaf;
//
//        private Double value;
//
//    }
//
//    @Data
//    public static class Feature{
//
//        private String type = "Feature";
//
//        private Properties properties;
//
//        private Map<String,Object> geometry;
//    }
//    public static RegionVO build(RegionEntity region, List<RegionEntity> child){
////        return build(region.getName(),region.getCode(), region.getPname(), region.getPcode(), region.getGeom(),child);
//        CrsProperties crsProperties = new CrsProperties();
//        crsProperties.setName("urn:ogc:def:crs:OGC:1.3:CRS84");
//
//        Crs crs = new Crs();
//        crs.setProperties(crsProperties);
//
//        RegionVO regionVO = new RegionVO();
//        if (StringUtils.isEmpty(region.getPname())){
//            regionVO.setName(region.getName());
//        }else {
//            regionVO.setName(region.getPname()+"-"+region.getName());
//        }
//        regionVO.setCrs(crs);
//
//        if (CollectionUtils.isEmpty(child)){
//            child = new ArrayList<>();
//            child.add(region);
//        }
//
//        List<Feature> features = new ArrayList<>();
//        for (RegionEntity childRegion : child){
//            Properties properties = new Properties();
//            properties.setCode(childRegion.getCode());
//            properties.setName(childRegion.getName());
//            properties.setPcode(childRegion.getPcode());
//            properties.setPname(childRegion.getPname());
//            properties.setX(childRegion.getX());
//            properties.setY(childRegion.getY());
//            properties.setLeaf(childRegion.getLeaf());
//            properties.setValue(getIndexValue(childRegion.getCode()));
//
//            Feature feature = new Feature();
//            feature.setProperties(properties);
//            feature.setGeometry(JsonUtils.jsonToMap(childRegion.getGeom(),Object.class));
//            features.add(feature);
//        }
//        regionVO.setFeatures(features);
//        return regionVO;
//    }
//
//    static IndexService indexService = SpringContextHolder.getBean(IndexService.class);
//
//    private static Double getIndexValue(String code){
//        try {
//            String value = (String)indexService.getIndexValue(code, "2023", "生态用地面积比指数");
//            return Double.valueOf(value);
//        }catch (Exception e){
////            e.printStackTrace();
//        }
//        return null;
//    }
//
////    public static RegionVO build(String name, String code, String pname, String pcode, String geom,List<RegionEntity> child){
////        CrsProperties crsProperties = new CrsProperties();
////        crsProperties.setName("urn:ogc:def:crs:OGC:1.3:CRS84");
////
////        Crs crs = new Crs();
////        crs.setProperties(crsProperties);
////
////        //
////        List<Feature> features = new ArrayList<>();
////        for (RegionEntity childRegion : child){
////
////        }
////        Properties properties = new Properties();
////        properties.setCode(code);
////        properties.setName(name);
////        properties.setPcode(pcode);
////        properties.setPname(pname);
////
////        Feature feature = new Feature();
////        feature.setProperties(properties);
////        feature.setGeometry(geom);
////
////
////        RegionVO regionVO = new RegionVO();
////        regionVO.setName(pname);
////        regionVO.setCrs(crs);
////        regionVO.setFeatures();
////        return regionVO;
////    }
//}
